package com.bw.demo_mvvm.ui

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView
import com.bw.demo_mvvm.R

class MvvmActivity : AppCompatActivity() {

    lateinit var tv: TextView
    private val mainViewModel: MvvmViewModel by lazy {
        MvvmViewModel()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_mvvm)
        tv = findViewById(R.id.tv)
    }

    fun getVideo(view: View) {
        mainViewModel.video(1, 10).observe(this){
            tv.text = "${it.data}"
        }
    }
}